package com.aaa.service.front.Impl;

import com.aaa.entity.Goods;
import com.aaa.entity.ShoppingCartDetail;
import com.aaa.mapper.front.ShoppingCartDetailMapper;
import com.aaa.service.front.IShoppingCartDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ShoppingCartDetailServiceImpl implements IShoppingCartDetailService {
    @Resource
    private ShoppingCartDetailMapper shoppingCartDetailMapper;


    @Override
    public List<ShoppingCartDetail> findShoppingCartDetail(Integer shoppingCartId) {
       return shoppingCartDetailMapper.findShoppingCartDetail(shoppingCartId);
    }

    @Override
    public int insertGoods(ShoppingCartDetail shoppingCartDetail) {
        return shoppingCartDetailMapper.insertGoods(shoppingCartDetail);
    }

    @Override
    public int updateGoodsNum(String goodsId, Integer shoppingCartId, Integer goodsCount) {
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("goodsId",goodsId);
        map.put("shoppingCartId",shoppingCartId);
        map.put("goodsCount",goodsCount);
        return shoppingCartDetailMapper.updateGoodsNum(map);
    }

    @Override
    public ShoppingCartDetail findShoppingCartDetailByGoodsIdAndShoppingCartId(String goodsId, Integer shoppingCartId) {
       Map<String,Object> map=new HashMap<String,Object>();
       map.put("goodsId",goodsId);
       map.put("shoppingCartId",shoppingCartId);
        return shoppingCartDetailMapper.findShoppingCartDetailByGoodsIdAndShoppingCartId(map);
    }


    @Override
    public int deleteGoodsDetail(Integer shoppingCartId, String goodsId) {
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("shoppingCartId",shoppingCartId);
        map.put("goodsId",goodsId);
        return shoppingCartDetailMapper.deleteGoodsDetail(map);
    }


}
